<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 输入年和月份显示当月天数 -->
    <!-- 输入年月日:
    <input id="year" type="text" />年
    <input id="month" type="text" />月
    <input type="button" value="显示当月天数" onclick="showDayCount()" />
    结果： <input id="dayCount" type="text" /><br /> -->
     <!-- <script>
        function showDayCount() {
            var year = document.getElementById("year").value
            var month = document.getElementById("month").value
            var dayCount = document.getElementById("dayCount").value
            if (month == 2) {
                if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
                    dayCount = "29天";
                }
                else {
                    dayCount = "28天";
                }
            }
            else if (month == 4 || month == 6 || month == 9 || month == 11) {
                dayCount = "30天";
            }
          else{
            dayCount = "31天";
          }
            document.getElementById("dayCount").value = dayCount;
        }

    </script>  -->
     <script>
        function showDayCount(year,month){
              var dayCount=0;
            if (month == 2) {
                if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
                    dayCount = "29天";
                }
                else {
                    dayCount = "28天";
                }
            }
            else if (month == 4 || month == 6 || month == 9 || month == 11) {
                dayCount = "30天";
            }
          else{
            dayCount = "31天";
          }
          return dayCount;
        }
        console.log(showDayCount(2005,5));  
     </script>
</body>

</html>